//index.js
//获取应用实例
const app = getApp();
var utils = require('../../utils/util.js');
var httpClient = require('../../utils/httpClient.js');
var serverConstants = require('../../constants/serverConstants.js');
Page({
  data: {
    good: {},
    showBid: false
  },
  onLoad: function (options) {
    this.getGoodInfo(options.code);
  },
  openEye: function () {
    var showBid = !this.data.showBid;
    this.setData({
      showBid: showBid
    });
  },
  getGoodInfo: function (goodCode) {
    var that = this;
    var shopId = wx.getStorageSync("shopId");
    httpClient.get('/good/view/' + shopId + '/' + goodCode, function (good) {
      good.price = utils.outputmoney(good.price);
      good.bid = utils.outputmoney(good.bid);
      good.picUrl = serverConstants.serverHost + good.picUrl;
      that.setData({
        good: good
      });
    });
  },
  //扫描商品
  scanCode: function () {
    var that = this;
    wx.scanCode({
      success: (res) => {
        var good = this.data.good;
        good.code = res.result;
        that.setData({
          good: good
        })
      }
    });
  }
})